﻿@{
    ViewBag.Title = "RoomMeter";
    Layout = "~/Views/Shared/_Form.cshtml";
}@using LeSoft.Application.Code;
<script>
    var _organizeid = "@OperatorProvider.Provider.Current().CompanyId";
    var keyValue = request('keyValue');
    var BillId = request('BillId');
    $(function () {
        initControl();
    })
    //初始化控件
    function initControl() {
        //性质
        $("#Nature").ComboBox({
            data: [{ "key": "1", "value": "单元表" }, { "key": "3", "value": "虚拟表" }],
            id: "key",
            text: "value",
            description: "==请选择==",
        });
        $("#Type").ComboBoxTree({
            url: "../../SystemManage/DataItemDetail/GetDataItemTreeJson?Encode=EnergyMeterType",
            description: "==请选表类型==",
            height: "250px"
        });
        $("#PStructId").ComboBoxTree({
            url: "../../ResourceManage/RS_PStructUser/GetRoomlist",
            param: { keyValue: BillId },
            description: "==请选所属房间==",
            height: "250px"
        });

        //获取表单
        if (!!keyValue) {
            var rowdata = top.Form.$("#gridTable_RoomMeter").jqGridRow()[0];
            $("#form1").SetWebControls(rowdata);
        }
    }
    //保存表单
    function AcceptClick() {
        if (!$('#form1').Validform()) {
            return false;
        }
        var $gridTable = top.Form.$("#gridTable_RoomMeter");
        var postData = $("#form1").GetWebControls("");
        postData["CreateUserName"] = $("#PStructId").attr("data-text");
        if (!!keyValue) {
            $gridTable.setRowData(keyValue, postData);
        } else {
            $gridTable.addRowData(($gridTable.jqGrid("getRowData").length + 1), postData);
        }
        dialogMsg("操作成功。", 1);
        dialogClose();
    }
</script>
<div style="margin-top: 20px; margin-right: 30px;">
    <table class="form">
        <tr>
            <td class="formTitle">所属房间<font face="宋体">*</font></td>
            <td class="formValue">
                <div id="PStructId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <td class="formTitle">表名称<font face="宋体">*</font></td>
            <td class="formValue">
                <input id="Name" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">表性质<font face="宋体">*</font></td>
            <td class="formValue">
                <div id="Nature" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <td class="formTitle">表类型<font face="宋体">*</font></td>
            <td class="formValue">
                <div id="Type" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>

        <tr>
            <td class="formTitle">备注</td>
            <td class="formValue">
                <textarea id="Description" class="form-control" style="height: 70px;"></textarea>
            </td>
        </tr>
    </table>

</div>

